<!--代码逻辑和样式库-->
<script src="./category-list.component.js"></script>
<style src="./category-list.scss" scoped lang="scss"></style>

<template>
  <div>
    <!-- 搜索区域 -->
    <div class="search-container">
      <el-form label-position="top" :inline="true">
        <el-row type="flex">
          <el-col :span="24" class="aq-vertical-middle">
            <el-input v-if="codesCheck.indexOf('Query') !== -1" v-model="searchCriteria.queryStr" placeholder="请输入车辆品牌名搜索信息" class="keyword" clearable @keyup.enter.native="search()"/>
            <el-button v-waves v-if="codesCheck.indexOf('Query') !== -1" type="primary" icon="el-icon-search" class="aq-margin-left-8" @click="search()">
              查询
            </el-button>
            <el-button v-waves v-if="codesCheck.indexOf('Query') !== -1" type="warning" icon="el-icon-refresh" @click="reset()">
              重置
            </el-button>
            <el-button v-waves v-if="codesCheck.indexOf('Create') !== -1" type="success" icon="el-icon-edit" @click="openEditDialog('create')">
              新增
            </el-button>
          </el-col>
        </el-row>
      </el-form>
    </div>
    <!-- 内容区域 -->
    <div class="content-container aq-margin-top-16">
      <!--用户角色table-->
      <el-table :data="data" border fit highlight-current-row @selection-change="handleSelectionChange">
        <!-- el-table-column type="selection" width="55" align="center" fixed></el-table-column -->
        <el-table-column prop="brandName" label="品牌名称" />
        <el-table-column prop="manufacturer" label="生产商" />
        <el-table-column prop="createTime" label="创建时间" />
        <el-table-column prop="trueName" label="创建人" />
        <el-table-column prop="text" label="操作" width="240px" align="center" fixed="right">
          <template slot-scope="scope">
            <el-link v-if="codesCheck.indexOf('Edit') != -1" icon="el-icon-edit" type="primary" @click="openEditDialog('edit', scope.row)">编辑</el-link>
            <!-- el-link class="aq-margin-left-16" icon="el-icon-connection" size="mini" type="success" @click="showCarDialog(scope.row)">查看详情</el-link -->
            <el-link class="aq-margin-left-16" v-if="codesCheck.indexOf('Delete') != -1" icon="el-icon-delete" size="mini" type="danger" @click="deleteSelectedData(scope.row.objectId)">删除</el-link>
          </template>
        </el-table-column>
      </el-table>
      <!-- 分页插件 -->
      <pagination v-show="totalNum > 0" :total="totalNum" :page.sync="pageNum" :limit.sync="recordNum" @pagination="getDataList" />
    </div>
    <!-- 创建/编辑角色 -->
    <el-dialog :title="dialogTitle" :visible.sync="editDialogVisible" width="500px">
      <el-form ref="dataForm" :model="editForm" :rules="editRules" label-position="left" label-width="100px">
        <el-row :gutter="20">
          <el-col :xs="24" :sm="24" :lg="24">
            <el-form-item prop="brandName" label="品牌名称">
              <el-input v-model="editForm.brandName" class="el-input-width" clearable maxlength="30" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :xs="24" :sm="24" :lg="24">
            <el-form-item label="生产商">
              <el-input v-model="editForm.manufacturer" class="el-input-width" clearable maxlength="50" show-word-limit />
            </el-form-item>
          </el-col>
        </el-row>
        <el-divider content-position="center">型号信息</el-divider>
        <el-row v-for="(item, index) in editForm.modelList" :key="index" :gutter="20" type="flex">
          <el-col :span="20">
            <el-form-item label="型号:">
              <el-input v-model="item.text" clearable maxlength="30" show-word-limit />
            </el-form-item>
          </el-col>
          <el-col :span="4" align="right">
            <el-button @click="deleteData(index)" type="danger" class="icon-button" icon="el-icon-delete" circle></el-button>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24" align="center">
            <el-button @click="addData()" type="success" class="icon-button" icon="el-icon-plus" circle></el-button>
          </el-col>
        </el-row>
        <el-row class="aq-margin-top-20">
          <el-col :xs="24" :sm="24" :lg="24" align="center">
            <el-button v-if="!editForm.objectId" type="primary" class="action-btn" @click="save()">立即创建</el-button>
            <el-button v-else type="primary" class="action-btn" @click="save()">提交</el-button>
            <el-button class="action-btn" @click="editDialogVisible = false">取消</el-button>
          </el-col>
        </el-row>
      </el-form>
    </el-dialog>
  </div>
</template>
